package com.skysail.service.impl;

import com.skysail.model.primary.UserModel;
import com.skysail.repository.primary.UserRepository;
import com.skysail.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {

//    @Autowired
//    @Qualifier("userRese")
//    private UserRepository userRepository;

    @Autowired
    private UserRepository userRepository;

    @Override
    public UserModel save(UserModel userModel) {
        return userRepository.save(userModel);
    }
    @Override
    public List<UserModel> findAll() {
        return userRepository.findAll();
    }

    @Override
    public UserModel findOne(String userName) {

        List<UserModel> userModels = userRepository.findByUserName(userName);
        return userModels.get(0);
    }

    @Override
    public boolean delete(Long id) {
        userRepository.deleteById(id);
        return true;
    }
}
